package auctiongui;


import auctioncentral.Item;
//import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

public class TableModel extends AbstractTableModel {

    private List<Item> my_item_list;
    private String[] columnNames = {"Item Number", "Name", "Quantity"};

    public TableModel(List<Item> the_list){
         my_item_list = the_list;
    }

    @Override
    public String getColumnName(int the_column_index){
         return columnNames[the_column_index];
    }

    @Override     
    public int getRowCount() {
        return my_item_list.size();
    }

    @Override        
    public int getColumnCount() {
        return 3; 
    }

    @Override
    public Object getValueAt(int the_row_index, int the_column_index) {
        Item si = my_item_list.get(the_row_index);
        switch (the_column_index) {
            case 0: 
                return si.getMy_id();
            case 1:
                return si.getName();
            case 2:
                return si.getQuantity();
           }
           return null;
   }

   @Override
   public Class<?> getColumnClass(int the_column_index){
          switch (the_column_index){
             case 0:
               return Integer.class;
             case 1:
               return String.class;
             case 2:
               return Integer.class;
             }
             return null;
      }
 }